namespace SiliverlightJavascriptIntelli
{
    public static class StringHelper
    {
        public static string Format(string str, string arg)
        {
            return str.Replace("{0}", arg);
        }

        public static string Format(string str, params string[] args)
        {
            string ReturnValue = str;

            for (int i = 0; i < args.Length; i++)
            {
                ReturnValue = ReturnValue.Replace("{" + i + "}", args[i]);
            }

            return ReturnValue;
        }

        public static string RemoveFunctionTrailingChars(string str)
        {
            return str.TrimEnd(' ', (char) 10, (char)13, ',');
        }

        public static string FirstLetterToLower(string name)
        {
            if (name.Length == 1)
                return name.ToLower();
            return name[0].ToString().ToLower() + name.Substring(1, name.Length - 1);
        }

        public static string ConvertToJSBool(bool value)
        {
            return StringHelper.FirstLetterToLower(value.ToString());
        }
    }
}